
package com.bear.cmcc.NetTestHTTP.component;

import com.bear.cmcc.NetTestHTTP.util.MyCommonUtil;

import java.util.ArrayList;
import java.util.HashMap;

import org.json.JSONObject;

public class CountryBean {

    /**
     * 本机设备网络名称。
     */
    private String selfNetType;

    /**
     * 本机设备IDMd5加密以后的值。
     */
    private String selfDeviceIdMd5;

    /**
     * 本机平均速度。
     */
    private double selfAverageSpeed;

    /**
     * 本机排名。
     */
    private int selfRand;

    /**
     * 全国2G平均速度。
     */
    private double AverageSpeed_2G = 0;

    /**
     * 全国TD平均速度。
     */
    private double AverageSpeed_TD = 0;

    /**
     * 全国2G设备数量。
     */
    private int size_2G = 0;

    /**
     * 全国TD设备数量。
     */
    private int size_TD = 0;
    
    /**
     * 全国TD、2G总数量（去掉重复的）
     */
    private int size_All = 0;
    /**
     * 2g、td全部设备
     */
    private JSONObject device2GAll = new JSONObject();
    private JSONObject deviceTDAll = new JSONObject();

    /**
     * 2G 网络速度省份信息。
     */
    private ArrayList<ProvinceBean> pri_2G = new ArrayList<ProvinceBean>();

    /**
     * TD 网络速度省份信息。
     */
    private ArrayList<ProvinceBean> pri_TD = new ArrayList<ProvinceBean>();
    
    public JSONObject getDevice2GAll() {
        return device2GAll;
    }

    public void setDevice2GAll(JSONObject _device2GAll) {
    	device2GAll = _device2GAll;
    }
    
    public JSONObject getDeviceTDAll() {
        return deviceTDAll;
    }

    public void setDeviceTDAll(JSONObject _deviceTDAll) {
    	deviceTDAll = _deviceTDAll;
    }
    
    public int getSize_All() {
        return size_All;
    }

    public void setSize_All(int size_all) {
    	size_All = size_all;
    }

    public double getAverageSpeed_2G() {
        return Double.valueOf(MyCommonUtil.getFormatString(AverageSpeed_2G));
    }

    public void setAverageSpeed_2G(double averageSpeed_2G) {
        AverageSpeed_2G = averageSpeed_2G;
    }

    public double getAverageSpeed_TD() {
        return Double.valueOf(MyCommonUtil.getFormatString(AverageSpeed_TD));
    }

    public void setAverageSpeed_TD(double averageSpeed_TD) {
        AverageSpeed_TD = averageSpeed_TD;
    }

    public int getSize_2G() {
        return size_2G;
    }

    public void setSize_2G(int size_2g) {
        size_2G = size_2g;
    }

    public int getSize_TD() {
        return size_TD;
    }

    public void setSize_TD(int size_TD) {
        this.size_TD = size_TD;
    }

    public ArrayList<ProvinceBean> getPri_2G() {
        return pri_2G;
    }

    public void addPri_2G(ProvinceBean my_pri_2g) {
        if (pri_2G != null && my_pri_2g != null) {
            pri_2G.add(my_pri_2g);
        }
    }

    public ArrayList<ProvinceBean> getPri_TD() {
        return pri_TD;
    }

    public void addPri_TD(ProvinceBean my_pri_TD) {
        if (pri_TD != null && my_pri_TD != null) {
            pri_TD.add(my_pri_TD);
        }
    }

    public String getSelfNetType() {
        return selfNetType;
    }

    public void setSelfNetType(String selfNetType) {
        this.selfNetType = selfNetType;
    }

    public String getSelfDeviceIdMd5() {
        return selfDeviceIdMd5;
    }

    public void setSelfDeviceIdMd5(String selfDeviceIdMd5) {
        this.selfDeviceIdMd5 = selfDeviceIdMd5;
    }

    public double getSelfAverageSpeed() {
        return Double.valueOf(MyCommonUtil.getFormatString(selfAverageSpeed));
    }

    public void setSelfAverageSpeed(double selfAverageSpeed) {
        this.selfAverageSpeed = selfAverageSpeed;
    }

    public int getSelfRand() {
        return selfRand;
    }

    public void setSelfRand(int selfRand) {
        this.selfRand = selfRand;
    }

    public int getProviceNumber() {
        int count = 27;
        try {
            HashMap<String, String> provices = new HashMap<String, String>();
            for (ProvinceBean element : pri_2G) {
                provices.put(element.getProvince_name().trim(), "");
            }
            for (ProvinceBean element : pri_TD) {
                provices.put(element.getProvince_name().trim(), "");
            }
            count = provices.keySet().size();
            provices.clear();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return count;
    }

    public int getCityNumber() {
        int count = 0;
        try {
            HashMap<String, String> citys = new HashMap<String, String>();
            for (ProvinceBean element : pri_2G) {
                for (CityBean city : element.get2GCitys()) {
                    citys.put(city.getCity_name().trim(), "");
                }
            }

            for (ProvinceBean element : pri_TD) {
                for (CityBean city : element.getTDCitys()) {
                    citys.put(city.getCity_name().trim(), "");
                }
            }
            count = citys.keySet().size();
            citys.clear();

        } catch (Exception e) {
            e.printStackTrace();
        }

        return count;

    }

}
